<?php

use think\migration\Seeder;
use app\admin\model\MemberModel;
use think\Db;

class MemberSeeder extends Seeder
{

    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * http://docs.phinx.org/en/latest/seeding.html
     */
    public function run()
    {
        for ($i = 0; $i <= 100; $i++) {
            $address = new MemberModel();
            $address->save($this->faker());
        }

    }

    public function faker()
    {

        $faker = Faker\Factory::create('zh_CN');
        // 头像假数据
        $avatars = [
            'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4285611627,3487298056&fm=26&gp=0.jpg',
            'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2884107401,3797902000&fm=26&gp=0.jpg',
            'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1700741544,1951185347&fm=26&gp=0.jpg',
            'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=571610305,1553276443&fm=26&gp=0.jpg',
            'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2060331795,864245471&fm=26&gp=0.jpg',
            'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=619291746,1342600010&fm=26&gp=0.jpg',
            'http://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTIugtrSgDVUkibZ1pXRka66WpX1zywfz14BoneqKc1AIBTVFT1icNJrKmhrwmmtPJryREqq8ialOxZfg/132',
            'http://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83epJCl9syicbX5EClc14AvY1ZIf0hHYcdSllWgo7ETkMWiamiahib6vQsibEFoe9oF7MUQjvPHlRRXNliaJQ/132',
        ];
        $level = [1, 2, 3, 4, 5];

        $avatar = $faker->randomElement($avatars);
        return [
            //随机获取一个用户
            'nickname'   => $faker->name,
            'avatar'     => $avatar,
            'openid'     => 'oVc9VwLbqm2zk7j0jHta9EarDDJ4',
            'level'      => $faker->randomElement($level),
            'talk_coin'  => mt_rand(1, 300),
            'coin'       => mt_rand(1, 300),
            'follow_num' => mt_rand(1, 300),
            'login_day'  => mt_rand(1, 300),
            'guess_num'  => mt_rand(1, 300),
        ];
    }
}